﻿//-----------------------------------------------------------------------
// <copyright file="EditWorkerWindow.xaml.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP_odb
{
    using System.Windows;
    using GalaSoft.MvvmLight.Messaging;
    using NMBP.Models;
    using NMBP.View.ViewModel;

    /// <summary>
    /// Interaction logic for EditWorkerWindow.xaml
    /// </summary>
    public partial class EditWorkerWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the EditWorkerWindow class
        /// </summary>
        public EditWorkerWindow()
        {
            InitializeComponent();
            Messenger.Default.Register<Worker>(
                this,
                "CloseEditWorkerWindow",
                (msg) =>
                {
                    AdminWindow adminWindow = new AdminWindow();
                    Messenger.Default.Send<Worker>(msg, "InitializeAdmin");
                    adminWindow.Show();
                    this.Close();
                });

            this.Closing += ((s,e) =>
                                 {
                                     Messenger.Default.Unregister(this);
                                     ViewModelLocator.ClearEditWorkerViewModel();
                                 })
            ;
        }
    }
}
